"""
URL configuration for devops_api project.

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/5.0/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include, re_path
from cmdb.views import IdcViewSet, ServerGroupViewSet, ServerViewSet, CreateHostView, ExcelCreateHostView, \
    AliyunCloudView, TencentCloudView
from system_config.views import CredentialViewSet
from rest_framework import routers

router = routers.DefaultRouter()
# cmdb项目相关接口
router.register(r'cmdb/idc', IdcViewSet, basename="idc")
router.register(r'cmdb/server_group', ServerGroupViewSet, basename="server_group")
router.register(r'cmdb/server', ServerViewSet, basename="server")
# credentials项目接口
router.register(r'config/credential', CredentialViewSet, basename="credential")

# token接口
from libs import token_auth

urlpatterns = [
    path('admin/', admin.site.urls),
    re_path('^api/login/$', token_auth.CustomAuthToken.as_view()),
    re_path('^api/change_password/$', token_auth.ChangeUserPasswordView.as_view()),
    re_path('^api/userlist/$', token_auth.UserList.as_view()),

    re_path('^api/cmdb/create_host/$', CreateHostView.as_view()),
    re_path('^api/cmdb/excel_create_host/$', ExcelCreateHostView.as_view()),
    re_path('^api/cmdb/aliyun_cloud/$', AliyunCloudView.as_view()),
    re_path('^api/cmdb/tencent_cloud/$', TencentCloudView.as_view())
]

urlpatterns += [
    path('api/', include(router.urls))
]
